import paddle


def load_pretrained(model, model_path=None):
    """加载预训练的模型

    Args:
        model (paddle.nn.Layer): 模型架构
        model_path (_type_, optional): 预训练模型的地址. Defaults to None.
    """
    model_state_dict = model.state_dict()
    pretrained_state_dict = paddle.load(model_path)
    model.set_state_dict(pretrained_state_dict)
